﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.InOut.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        private readonly IMediator _mediator;

        public ProductController(IMediator mediator)
        {
            _mediator = mediator;
        }

        
        // 获取产品的 HTTP GET 方法
        [HttpGet("{id}")]
        public async Task<IActionResult> Get(int id)
        {
            var request = new GetProductRequest { ProductId = id };
            var result = await _mediator.Send(request);
            return Ok(result);
        }
    }
}
